package com.ll.trydemo;

import java.util.Scanner;

/**
 * @author 刘龙
 * @version 1.0
 */
public class TryCatchExercise04 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int num = 0;
        String inputStr = "";

        while (true) {
            System.out.println("请输入一个整数");
            inputStr = scanner.next();
            try {
                num = Integer.parseInt(inputStr);
                break;
            } catch (NumberFormatException e) {
                System.out.println("你输入的不是整数");
            } finally {
                System.out.println("哈哈哈");
            }
        }

        System.out.println("inputStr: " + inputStr);
        System.out.println("num: " + num);
    }
}
